package com.peaksport.pkms.leanrtest1.service;

import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable;
import org.apache.servicecomb.pack.omega.transaction.annotations.Participate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.peaksport.framework.base.dao.IBaseDAO;
import com.peaksport.framework.base.service.BillBaseService;
import com.peaksport.framework.exception.PKBizException;
import com.peaksport.framework.exception.PKDevException;

@Service
public class TestPackTcc1Service extends BillBaseService {

	@Override
	public IBaseDAO<?> getDAO() {
		// TODO Auto-generated method stub
		return null;
	}
	
	
	@Participate(confirmMethod="auditBillEntryForTcc_confirm",cancelMethod="auditBillEntryForTcc_cancel")
	@Transactional
	public void auditBillEntryForTcc(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String checkSql = "select FLineStatus from t_tst_billentry where FParentId='" + pk + "'";
		boolean b = isExistsForNative(checkSql);
		if (!b) throw PKBizException.throwException("不存在分录记录[%s]", pk);
		String updSql= "update t_tst_billentry set FLineStatus=99 where FParentId='" + pk + "'";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillEntryForTcc");
		if (isException) throw PKDevException.throwException("审核分录表.try发生异常");
	}
	
	@Transactional
	public void auditBillEntryForTcc_confirm(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String updSql= "update t_tst_billentry set FLineStatus=4 where FParentId='" + pk + "' and FLineStatus=99";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillEntryForTcc_confirm");
		if (isExceptionInConfirm) throw PKDevException.throwException("审核分录表.confirm发生异常");
		
	}
	@Transactional
	public void auditBillEntryForTcc_cancel(String pk,boolean isException, boolean isExceptionInConfirm, boolean isExceptionInCancel) {
		String updSql= "update t_tst_billentry set FLineStatus=0 where FParentId='" + pk + "'and FLineStatus=99";
		executeSqlForNative(updSql.toString());
		System.out.println("auditBillEntryForTcc_cancel");
		if (isExceptionInCancel) throw PKDevException.throwException("审核分录表.cancel发生异常");
	}
	

}
